package com.snake.win;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.viewport.FitViewport;
import com.snake.win.screen.MainMenuScreen;
import com.snake.win.web.Client;
import com.snake.win.web.Server;


/**
 * {@link com.badlogic.gdx.ApplicationListener} implementation shared by all platforms.
 */
public class GameWin extends Game {

    public SpriteBatch batch;
    public BitmapFont font;
    public FitViewport viewport;

    public Server server;
    public Client client;

    @Override
    public void create() {
        batch = new SpriteBatch();
        font = new BitmapFont(Gdx.files.internal("font/font.fnt"));
        viewport = new FitViewport(900, 600);
        //font.setUseIntegerPositions(false);
        //font.getData().setScale(viewport.getWorldHeight() / Gdx.graphics.getHeight());

        server = new Server();
        client = new Client();

        this.setScreen(new MainMenuScreen(this));
    }



    @Override
    public void render() {
        super.render();
    }

    @Override
    public void dispose() {
        batch.dispose();
        font.dispose();

        if (server != null) {
            server.stop();
        }
        if (client != null && client.isConnected()) {
            client.disconnect();
        }
    }

}
